/**
 *  该文件的适用于创建一个为 Count组件服务的Reducer，Reducer的本质就是一个函数
 */
import {INCREMENT, DECREMENT} from "../constant";

const initState = 0;        // 初始化状态
export default function counterReducer(preState = initState, action) {
	const {type, data} = action;
	switch (type) {
		case INCREMENT:
			return preState + data;
		case DECREMENT:
			return preState - data;
		default:
			return preState;
	}
}
